import { reqSearchList, reqtAutoList, reqtHotList } from "@/api"

export default {
    state: {
        aa: 1,
        hotList: [],
        autoList: [],
        shopList:[]
    },
    mutations: {
        SERT_HOT_LIST(state, data) {
            state.hotList = data
        },
        SET_ATUO_LIST(state, data) {
            state.autoList = data
        },
        SET_SHOP_LIST(state, data) { 
            state.shopList = data
        }
    },
    actions: {
        async getHost({ commit }) {
            let res = await reqtHotList();
            if (res.code == 200) {
                commit('SERT_HOT_LIST', res.data.hotKeywordVOList)
            }
        },
        async getAutoList({ commit }, keywordPrefix) { 
            let res = await reqtAutoList(keywordPrefix)
            if (res.code == 200) { 
                commit('SET_ATUO_LIST',res.data)
            }
        },
        async getSearchList({ commit }, key) { 
            let res = await reqSearchList(key)
            if (res.code == 200) {
                commit('SET_SHOP_LIST', res.data.directlyList)
                return 'ok'
            } else { 
                return Promise.reject()
            }
            
        }
    },
    getters: {}
}